class Solution:
    def numberOfArrays(self, s: str, k: int) -> int:
        MOD = 10**9+7
        dp = [0 for _ in range(len(s)+1)]
        dp[0] = 1
        kLen = len(str(k))
        for i in range(len(s)):
            for j in range(kLen):
                if i < j:
                    break
                if s[i-j:i+1].startswith('0'):
                    continue
                if int(s[i-j:i+1]) <= k:
                    dp[i+1] += dp[i-j] % MOD

        return dp[-1] % MOD
